<?php
require_once('./admin/connexion.php');
require ('./func.req.php');
if ($install) {
    ?>
    <link rel="stylesheet" type="text/css" href="./css/style.css" title="" media="all" />
    <div id="box" onclick="document.getElementById('box').style.display='none';" style="margin:20%;" class="error-box rounded" title="Fermer la fen&ecirc;tre">
        L'installation n'a pas encore &eacute;t&eacute; r&eacute;alis&eacute;e. <a href="./install/index.php">Cliquez ici</a> pour commencer.
    </div>
    <?php
} else {
    require('./config/tbl.php');
    if ($line_info['maintenance_choix_info'] == "Oui") {
        show_maintenance();
    } else {

        /*
          -----------------------------------
          ---- SCRIPT D'AUTHENTIFICATION ----
          FujiCraft V3.0
          By Fujido
          Contact : thefujido@gmail.com
          -----------------------------------
         */

        session_start(); // On relaye la session
        if (@session_is_registered("authentification")) { // v�rification sur la session authentification (la session est elle enregistr�e ?)
// ici les �ventuelles actions en cas de r�ussite de la connexion
        } else {
            header("Location:login.php?erreur=needlog"); // redirection en cas d'echec
        }

// GESTION DE LA D�connexion
        if (isset($_GET['erreur']) && $_GET['erreur'] == 'logout') { // Test sur les param�tres d'URL qui permettront d'identifier un "contexte" de d�connexion
            $prenom = $_SESSION['prenom']; // On garde le pr�nom en variable pour dire au revoir (soyons polis :-)
            @session_unset("authentification");
            header("Location:login.php?erreur=logout");
        }
        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
                <title><?php echo $site; ?> | Voir les commentaires de <?php echo $_GET['user']; ?></title>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <meta http-equiv="Content-Style-Type" content="text/css" />
                <meta http-equiv="content-language" content="fr,en" />
                <link rel='shortcut icon' type="image/x-icon" href='./images/favicon.ico' />
                <link rel="stylesheet" type="text/css" href="./css/style.css" title="" media="all" />
                <link rel="stylesheet" type="text/css" href="./css/register.css" title="" media="all" />
                <link rel="stylesheet" type="text/css" href="./css/news.css" title="" media="all" />
                <script type="text/javascript" src="./js/news.js"></script>
            </head>
            <body>
                <div id="block">
                    <div id="contentblock">
                        <div class="wrapper">
                            <?php
                            show_header();
                            show_menu();
                            show_newsbox();
                            show_userbox();
                            ?>
                            <div class="mainbox">
                                <h2>Commentaires de <?php echo $_GET['user']; ?></h2>
                                <br />
                                <center>
                                    <?php
                                    $user = $_GET['user'];
                                    //Selection de la table
                                    $query_com = "SELECT * FROM " . $database . "." . $tb_comment . " WHERE author_com = '$user' ORDER BY date_com desc";
                                    //Affichage de la selection
                                    $result_com = @mysql_query($query_com) OR DIE("Erreur de la s&eacute;lection des commentaires : " . mysql_error());
                                    if (mysql_num_rows($result_com) == 0) {
                                        ?>
                                        <div id="box" onclick="document.getElementById('box').style.display='none';" class="info-box rounded" title="Fermer la fen&ecirc;tre">
                                            L'utilisateur n'a encore post&eacute; aucun commentaire.
                                        </div>
                                        <?php
                                    }
                                    while ($line = mysql_fetch_assoc($result_com)) {
                                        $date_usa = $line['date_com'];
                                        $date = substr($date_usa, 8, 10) . "/" . substr(substr($date_usa, 5, 7), 0, 2) . "/" . substr($date_usa, 0, 4);
                                        $heure_usa = $line['heure_com'];
                                        $heure = substr($heure_usa, 0, 2) . "h" . substr($heure_usa, 3, 5);
                                        ?>
                                        <div class="comment-box rounded">
                                            Post&eacute; par <b><a href="./user.php?user=<?php echo $line['author_com']; ?>" title="Voir le profil de <?php echo $line['author_com']; ?>"><?php echo $line['author_com']; ?></a></b>, le <i><?php echo $date; ?></i> &agrave; <i><?php echo $heure; ?></i><br />
                                            <br />
                                            <?php echo addChar(utf8_encode($line['comment_com'])); ?> <br />
                                            <br />
                                            <b class="right px10"><i><a href="./comment.php?news=<?php echo $line['id_news_com']; ?>">Voir la news</a></i></b>
                                        </div>  
                                        <?php
                                    }
                                    ?>
                                    <br />
                                    <br />
                                    <br />
                                    <br />
                                    <a href="./user.php?user=<?php echo $_GET['user']; ?>&action=back" class="btn">Retourner sur le profil de <?php echo $_GET['user']; ?></a>
                                </center>
                                <br />
                            </div>
                            <?php show_footer(); ?>
                        </div>
                    </div>
                </div>
            </body>
        </html>
        <?php
    }
}
?>